﻿namespace UnityEditor
{
    using System;

    public class VCMenuProject
    {
        private static void CheckOut(MenuCommand cmd)
        {
            VCAssetList selected = VCDatabase.selected;
            VCProvider.Checkout(selected, CheckoutMode.Both);
            VCDatabase.Invalidate(selected);
        }

        private static bool CheckOutTest(MenuCommand cmd)
        {
            return (VCProvider.enabled && VCProvider.CheckoutIsValid(VCDatabase.selected));
        }

        private static void DiffHead(MenuCommand cmd)
        {
            VCProvider.DiffHead(VCDatabase.selected);
        }

        private static bool DiffHeadTest(MenuCommand cmd)
        {
            return (VCProvider.enabled && VCProvider.DiffIsValid(VCDatabase.selected));
        }

        private static void GetLatest(MenuCommand cmd)
        {
            VCAssetList selected = VCDatabase.selected;
            VCProvider.GetLatest(selected);
            VCDatabase.Invalidate(selected);
        }

        private static bool GetLatestTest(MenuCommand cmd)
        {
            return (VCProvider.enabled && VCProvider.GetLatestIsValid(VCDatabase.selected));
        }

        private static void Lock(MenuCommand cmd)
        {
            VCAssetList selected = VCDatabase.selected;
            VCProvider.Lock(selected, true);
            VCDatabase.Invalidate(selected);
        }

        private static bool LockTest(MenuCommand cmd)
        {
            return (VCProvider.enabled && VCProvider.LockIsValid(VCDatabase.selected));
        }

        private static void MarkAdd(MenuCommand cmd)
        {
            VCAssetList selected = VCDatabase.selected;
            VCProvider.Add(selected);
            VCDatabase.Invalidate(selected);
        }

        private static bool MarkAddTest(MenuCommand cmd)
        {
            return (VCProvider.enabled && VCProvider.AddIsValid(VCDatabase.selected));
        }

        private static void Revert(MenuCommand cmd)
        {
            VCWindowRevert.Open(VCDatabase.selected);
        }

        private static bool RevertTest(MenuCommand cmd)
        {
            return (VCProvider.enabled && VCProvider.RevertIsValid(VCDatabase.selected, false));
        }

        private static void RevertUnchanged(MenuCommand cmd)
        {
            VCAssetList selected = VCDatabase.selected;
            VCProvider.Revert(selected, true);
            VCDatabase.Invalidate(selected);
        }

        private static bool RevertUnchangedTest(MenuCommand cmd)
        {
            return (VCProvider.enabled && VCProvider.RevertIsValid(VCDatabase.selected, true));
        }

        private static void Submit(MenuCommand cmd)
        {
            VCWindowChange.Open(VCDatabase.selected, true);
        }

        private static bool SubmitTest(MenuCommand cmd)
        {
            return (VCProvider.enabled && VCProvider.SubmitIsValid(null, VCDatabase.selected));
        }

        private static void Unlock(MenuCommand cmd)
        {
            VCAssetList selected = VCDatabase.selected;
            VCProvider.Lock(selected, false);
            VCDatabase.Invalidate(selected);
        }

        private static bool UnlockTest(MenuCommand cmd)
        {
            return (VCProvider.enabled && VCProvider.UnlockIsValid(VCDatabase.selected));
        }
    }
}

